@echo off

rem =======================================================
rem             feeling-lucky-launcher.bat
rem =======================================================
rem Author: Gareth Woodham
rem Date:   2013-09-08
rem
rem Script to launch a random ROM into an emulator.
rem If using Windows XP then download FreeDOS choice.exe.
rem =======================================================

rem -------------------------------------------------------
:INIT
set LAUNCH_DIR=%CD%

rem -------------------------------------------------------
:HELP
call:BANNER
ver
echo Emulator ............ %EMU_HOME%\%EMU_EXEC%
echo ROM directory ....... %ROM_HOME%
echo history.dat path .... %DAT_PATH%
echo.
echo Button Commands:
echo Insert Coin ......... Quit
echo Player 1 ............ Next Game
echo Player 2 ............ Start Game

rem -------------------------------------------------------
:START
cls
cd %LAUNCH_DIR% >NUL
java FeelingLuckyLauncher %ROM_HOME%>tmp
set /p rom=<tmp

rem -------------------------------------------------------
:DISPLAY   
if %EMU_EXEC% == mame.exe (
	java FeelingLuckyLauncher %DAT_PATH% %rom%
	%EMU_HOME%\%EMU_EXEC% -listfull %rom%
) else (
	echo %rom%
)                

rem -------------------------------------------------------
:CHOOSE
choice /C:512 /N >NUL
IF ERRORLEVEL 3 goto LOAD
IF ERRORLEVEL 2 goto START
IF ERRORLEVEL 1 goto QUIT

rem -------------------------------------------------------
:LOAD
cd %EMU_HOME% >NUL
%EMU_EXEC% %EMU_PARAMS% %rom% 2>NUL >NUL
goto START

rem -------------------------------------------------------
:QUIT
cd %LAUNCH_DIR% >NUL
pause
goto:EOF
